package com.open4cn.simulator.core.connector;

import java.io.Serializable;

/**
 * @author yinxiaopeng
 * @version 1.0.0
 * @company 致景科技
 * @department 飞梭BU/研发
 * @description 连接状态
 * @Email yinxiaopeng@zj.tech
 * @date 2022-03-15 00:17
 */
public class ConnectStatus implements Serializable {

    private StatusEnum status;


    public ConnectStatus() {
        this.status = StatusEnum.WAITING;
    }

    public StatusEnum getStatus() {
        return status;
    }

    /**
     * 是否等待状态
     *
     * @return
     */
    public boolean isWaiting() {
        return StatusEnum.WAITING.equals(status);
    }

    /**
     * 是否连接状态
     *
     * @return
     */
    public boolean isConnected() {
        return StatusEnum.CONNECTED.equals(status);
    }


    /**
     * 是否关闭状态
     *
     * @return
     */
    public boolean isClosed() {
        return StatusEnum.CLOSED.equals(status);
    }


    /**
     * 连接
     */
    public void beConnect() {
        this.status = StatusEnum.CONNECTED;
    }

    /**
     * 关闭连接
     */
    public void beClose() {
        this.status = StatusEnum.CLOSED;
    }

    /**
     * 连接失败
     */
    public void beFail() {
        this.status = StatusEnum.CONNECT_FAIL;
    }

    public enum StatusEnum {
        WAITING,
        CONNECTED,
        CONNECT_FAIL,
        CLOSED;
    }


}
